//#include <boost/signals2.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <string>

using namespace std;

template<typename F>
using event = boost::signals2::signal<F>;   // needs g++4.7 above, -std=c++11


class Huyi
{
public:
    Huyi(string const &as)
        :s(as)
    { 
        OnSayHi.connect(boost::bind(&Huyi::myself, this, _1)); 
    }

    typedef event<void (string const&)> HiEvent;
    HiEvent OnSayHi;

    void missYou() { OnSayHi(s); }

private:
    void myself(string const&) { cout << s << endl; }
    string s;
};

class Yu
{
public:
    void OnSayHi(string const &s) { cout << "Yu got you message: " + s + " :)" << endl; }
    //void OnSayHi(string &s) { cout << "Yu got you message: " + s + " :)" << endl; }
};


int main()
{
    string s = "I miss you so much, speak to me";
    Huyi hi(s);
    Yu yu;

    hi.OnSayHi.connect(boost::bind(&Yu::OnSayHi, boost::ref(yu), _1));

    hi.missYou();
}

